import Vue from 'vue'
import Vuex from 'vuex'
import { getItem, setItem } from '../utils/storage'

Vue.use(Vuex)
const BI = 'bili'
const userinfo = 'bilibi-user'
export default new Vuex.Store({
  state: {
    user: getItem(BI),
    profile: getItem(userinfo)
  },
  mutations: {
    setUser(state, data) {
      state.user = data
      setItem(BI, data)
    },
    setProfile(state, data) {
      state.profile = data
      setItem(userinfo, data)
    }
  },
  actions: {
  },
  modules: {
  }
})
